<%-- 
    Document   : Search
    Created on : Dec 4, 2012, 11:36:17 PM
    Author     : Quang Thao
--%>

<%@page import="java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Search account</title>
        <%@include file="../LayoutAdmin/InHead.jsp" %>
    </head>
    <body>
        <div id="horizontal_bar">
            <div id="wrapper">
                <%@include file="../LayoutAdmin/Top.jsp" %>
                <div id="middle">
                    <%@include file="../LayoutAdmin/Middle_Top.jsp" %>
                    <div class="left">
                        <div class="menuitem_ulstyle_vertical">
                            <ul>
                                <li>
                                    <a href="Add.jsp">Thêm</a>
                                </li>
                                <li>
                                    <a href="Delete.jsp">Xóa</a>
                                </li>
                                <li>
                                    <a href="Search.jsp">Tra cứu</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                    <div class="bar_bt_lr"></div>
                    <div class="right">
                        <form action="../../SearchAccountServlet" method="POST">
                            <h1>Tra cứu tài khoản</h1>
                            <table class="Table2">
                                <tr>
                                    <td>Loại tài khoản :</td>
                                    <td>
                                        <select name="cbxType">
                                            <option value="all">Tất cả</option>
                                            <option value="adm">Admin</option>
                                            <option value="sup">Supporter</option>
                                            <option value="mem">Member</option>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <th colspan="2">
                                        <input type="submit" value="Tìm" name="btnFind" 
                                               class="Button1"/>
                                    </th>
                                </tr>
                            </table>
                            <table class="Table3">
                                <tr>
                                    <th>Tên tài khoản</th>
                                    <th>Họ tên</th>
                                    <th>Email</th>
                                    <th>Địa chỉ</th>
                                    <th>Số điện thoại</th>
                                    <th>Loại tài khoản</th>
                                </tr>
                                <%
                                    BO.AccountBO accBO = new BO.AccountBO();
                                    List listAcc = new ArrayList<Bean.AccountBean>();

                                    String key = null;
                                    if (request.getQueryString() != null) {
                                        key = request.getQueryString().split("=")[1];
                                        if (key.equals("all")) {
                                            listAcc = accBO.GetAll();
                                        } else {
                                            listAcc = accBO.GetListByType(key);
                                        }
                                    } else {
                                        listAcc = accBO.GetAll();
                                    }

                                    for (int i = 0; i < listAcc.size(); i++) {
                                        Bean.AccountBean accTemp = (Bean.AccountBean) listAcc.get(i);
                                %>
                                <tr>
                                    <td><%= accTemp.getID()%></td>
                                    <td><%= accTemp.getName()%></td>
                                    <td><%= accTemp.getEmail()%></td>
                                    <td><%= accTemp.getAddress()%></td>
                                    <td><%= accTemp.getPhone()%></td>
                                    <td><%= accTemp.getTypeMean()%></td>
                                </tr>
                                <%
                                    }
                                %>
                            </table>
                        </form>
                    </div>
                </div>
                <%@include file="../LayoutUser/Bottom.jsp" %>
            </div>
        </div>
    </body>
</html>
